package genetica.cromosomas.factorias;

import genetica.cromosomas.Cromosoma;
import genetica.cromosomas.CromosomaFuncion;
import genetica.cromosomas.evaluadores.evaluadorFuncionE;

import java.util.ArrayList;
import java.util.Random;

public class factoriaFuncionE extends FactoriaFuncion {



	public factoriaFuncionE( double precision){
		super(precision);
	}

	@Override
	public Cromosoma crea() {
		Random r = new Random();
		ArrayList<Double> xmin = new ArrayList<Double>();
		ArrayList<Double> xmax = new ArrayList<Double>();
		for (int i = 0; i < 2; i++) {
			xmin.add(-10.0);
			xmax.add(10.0);
		}
		Cromosoma c = new CromosomaFuncion(xmin, xmax, precision, r,
				new evaluadorFuncionE());
		return c;
	}

	@Override
	public Cromosoma copia(Cromosoma original) {
		if (original instanceof CromosomaFuncion)
			return new CromosomaFuncion((CromosomaFuncion) original);
		else
			return null;
	}
	@Override
	public String toString(){
		return "f(x1,x2) = ((i=1..5)∑(i·cos(( +1) x1 + i))) x ((i=1..5)∑(i·cos(( +1) x2 + i))) : xi ∈ [-10,10]";
	}
}
